const app = getApp();
var {
  Api
} = require('../../api/api')
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    mask:{
      type:Boolean,
      value:false
    },
    shulist:{
      type:Array,
      value:''
    },
    shuid:{
      type:Array,
      value:''
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    shuid:[],
    domain: Api.domain,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    noMask(){
      this.setData({
        mask:false
      })
    },
    check(e){//书目筛选
      const {index} = e.currentTarget.dataset
      const {flage} = e.currentTarget.dataset
      const {id} = e.currentTarget.dataset
      let {shuid} = this.data
      // arr= arr.filter((x) => x !== '待删除元素');
      this.setData({
        [`shulist[${index}].flage`]:!this.data.shulist[index].flage
      })
      if(flage){
        shuid = shuid.concat(id)
        this.setData({
          shuid
        })
        console.log(this.data.shuid)
      }else{
        let arr= shuid.filter((x) => x !== id)
        this.setData({
          shuid:arr
        })
        console.log(this.data.shuid)
      }
    },
    sure(){//确定
      this.noMask()
      var pageArr = getCurrentPages();
      var thisPage = pageArr[pageArr.length - 1];
      thisPage.setData({
        shuid:this.data.shuid
      })
      thisPage.init()
    }
  }
})
